<?php $this->_extends('../_layouts/default_layout'); ?>
<?php $this->_block('contents'); ?>
<link type="text/css" href="<?=Q::ini('custom_system/base_url')?>css/jq.mselect.css" rel="stylesheet" />
<link type="text/css" href="<?=Q::ini('custom_system/base_url')?>css/prettyphoto.css" rel="stylesheet" />
<script type="text/javascript" src="<?=Q::ini('custom_system/base_url')?>js/jq.mselect.js"></script>
<script type="text/javascript" src="<?=Q::ini('custom_system/base_url')?>js/jq.multiselect.js"></script>
<script type="text/javascript" src="<?=Q::ini('custom_system/base_url')?>js/jq.prettyphoto.js"></script>
<script type="text/javascript">
get_check = function(){
	var ids = '';
	$("#list").find("input[type='checkbox']").each(function(){
		if ($(this).is(":checked"))
		{
			if (ids)
			{
				ids += ',';
			}
			ids += $(this).val();
		}
	});
	return ids;
}
$(function(){
	$("a[rel^='pretty_photo']").prettyPhoto({theme:'facebook'});
	$(".datepicker").datepicker({dateFormat:'yy-mm-dd',changeMonth:true});
	$("#dialog_trash").dialog({autoOpen:false,modal:true});
	$("#dialog_combine").dialog({autoOpen:false,modal:true, height: 300, width: 200});
	$("#dialog_notes").dialog({autoOpen:false,modal:true, height: 300, width: 400});
	$("#dialog_order_notes").dialog({autoOpen:false,modal:true, height: 300, width: 400});
	$("#dialog_refund").dialog({autoOpen:false,modal:true, height: 300, width: 600});
	$("#dialog_markorder").dialog({autoOpen:false,modal:true, height: 180, width: 350});
	$("#multiselect").multiselect({height: 260, minWidth: 160});
	$("#dialog_change_shipping_method").dialog({autoOpen:false, modal:true});
	$(".more_click").mouseover(function(){
		$(this).next().show();
	}).mouseout(function(){
		$(this).next().hide();
	});
	$(".trash_click").click(function(){
		$("#trash_id").val($(this).next().val());
		$("#dialog_trash").dialog("open");
	});
	$(".combine_click").click(function(){
		$("#combine_order_id").val($(this).next().val());
		var combine_order_id = $(this).next().val();
		$("#dialog_combine").dialog("open");
		var ids = new Array();
		$("#list").find("input[type='checkbox']").each(function(){
			if ($(this).is(":checked"))
			{
				if (combine_order_id != $(this).val())
				{
					ids.push($(".number"+$(this).val()).text());
				}
			}
		});
		ids = ids.join('\n');
		$("#number").val(ids);
	});
	$(".markorder_click").click(function(){
		$("#markorder_id").val($(this).next().val());
		$("#dialog_markorder").dialog("open");
	});
	$(".refund_click").click(function(){
		$("#refund_id").val($(this).next().val());
		$("#dialog_refund").dialog("open");
	});
	$(".trash_btn").click(function(){
		$("#trash_id").val($(this).prev().prev().val());
		$("#dialog_trash").dialog("open");
	});
	$(".multi_checkout_btn").click(function(){
		var ids = new Array();
		$("#list").find("input[type='checkbox']").each(function(){
			if ($(this).is(":checked"))
			{
				ids.push($(this).val());
			}
		});
		if (ids.length == 0)
		{
			alert("请选择订单");
			return false;
		}
		$("#info").val(ids);
		$("#action_form").attr("action", "<?=url('Sales::Order/MultiCheckOut')?>").submit();
	});
	$(".checkout_btn").click(function(){
		var id = $(this).next().val();
		var current = $(this);
		$.ajax({
			type: "GET",
			url: "<?=url('Sales::Order/CheckOut')?>&id=" + id,
			dataType: "text",
			success:
				function(data)
				{
					alert(data);
					current.attr("disabled", true);
				}
		});
	});
	$(".multi_hold_btn").click(function(){
		var ids = new Array();
		$("#list").find("input[type='checkbox']").each(function(){
			if ($(this).is(":checked"))
			{
				ids.push($(this).val());
			}
		});
		if (ids.length == 0)
		{
			alert("请选择订单");
			return false;
		}
		$("#info").val(ids);
		$("#action_form").attr("action", "<?=url('Sales::Order/MultiSalesHold')?>").submit();
	});
	$(".hold_btn").click(function(){
		var id  = $(this).prev().val();
		var current = $(this);
		$.ajax({
			type: "GET",
			url: "<?=url('Sales::Order/SalesHold')?>&id=" + id,
			dataType: "text",
			success: 
				function(data)
				{
					alert(data);
					current.attr('disabled', true);
				}
		});
	});
	$(".removed_eub_btn").click(function(){
		var current_tag = $(this);
		var id = current_tag.prev().prev().prev().prev().prev().val();
		$.ajax({
			type: "GET",
			url: "<?=url('Sales::Order/RemovedEUBpackage')?>&id=" + id,
			dataType: "json",
			beforeSend: 
				function(){
					current_tag.attr("disabled",true);
					current_tag.next().html("<img src='<?=Q::ini('custom_system/base_url')?>img/loading.gif' />");
				},
			success:
				function(data)
				{
					if (data['ack']=='success')
					{
						current_tag.next().html(data['message']);
						current_tag.prev().prev().attr("disabled", false);
					}
					else
					{
						current_tag.attr("disabled", false);
						current_tag.next().html(data['message']);
					}
				},
			error:
				function()
				{
					current_tag.attr("disabled", false);
					current_tag.next().html('亲，网络问题，再来一次');
				}
		});
	});
	$(".post_eub_btn").click(function(){
		var current_tag = $(this);
		var id = current_tag.prev().prev().prev().val();
		$.ajax({
			type: "GET",
			url: "<?=url('Sales::Order/PostEUBPackage')?>&id=" + id,
			dataType: "json",
			beforeSend: 
				function(){
					current_tag.attr("disabled",true);
					current_tag.next().html("<img src='<?=Q::ini('custom_system/base_url')?>img/loading.gif' />");
				},
			success:
				function(data)
				{
					if (data['ack']=='success')
					{
						current_tag.next().html(data['message']);
					}
					else
					{
						current_tag.attr("disabled", false);
						current_tag.next().html(data['message']);
					}
				},
			error:
				function()
				{
					current_tag.attr("disabled", false);
					current_tag.next().html('亲，网络问题，再来一次');
				}
		});
	});
	$(".post_ieub_btn").click(function(){
		var current_tag = $(this);
		var id = current_tag.prev().prev().prev().val();
		$.ajax({
			type: "GET",
			url: "<?=url('Sales::Order/PostIEUBPackage')?>&id=" + id,
			dataType: "json",
			beforeSend: 
				function(){
					current_tag.attr("disabled",true);
					current_tag.next().html("<img src='<?=Q::ini('custom_system/base_url')?>img/loading.gif' />");
				},
			success:
				function(data)
				{
					if (data['ack']=='success')
					{
						current_tag.next().html(data['message']);
					}
					else
					{
						current_tag.attr("disabled", false);
						current_tag.next().html(data['message']);
					}
				},
			error:
				function()
				{
					current_tag.attr("disabled", false);
					current_tag.next().html('亲，网络问题，再来一次');
				}
		});
	});
	$(".removed_ieub_btn").click(function(){
		var current_tag = $(this);
		var id = current_tag.prev().prev().prev().prev().prev().val();
		$.ajax({
			type: "GET",
			url: "<?=url('Sales::Order/RemovedIEUBPackage')?>&id=" + id,
			dataType: "json",
			beforeSend: 
				function(){
					current_tag.attr("disabled",true);
					current_tag.next().html("<img src='<?=Q::ini('custom_system/base_url')?>img/loading.gif' />");
				},
			success:
				function(data)
				{
					if (data['ack']=='success')
					{
						current_tag.next().html(data['message']);
						current_tag.prev().prev().attr("disabled", false);
					}
					else
					{
						current_tag.attr("disabled", false);
						current_tag.next().html(data['message']);
					}
				},
			error:
				function()
				{
					current_tag.attr("disabled", false);
					current_tag.next().html('亲，网络问题，再来一次');
				}
		});
	});
	$(".addnotes_click").click(function(){
		$("#notes_id").val($(this).next().val());
		$("#dialog_notes").dialog("open");
	});
	$(".addordernotes_click").click(function(){
		$("#order_notes_id").val($(this).next().val());
		$("#dialog_order_notes").dialog("open");
	});
	$(".more_content").mouseover(function(){
		$(this).show();
	}).mouseout(function(){
		$(this).hide();
	});
	$(".view").toggle(function(){
		$(this).parent().parent().next().show();
	},function(){
		$(this).parent().parent().next().hide();
	});
	$("#handle_status input[type='checkbox']").change(function(){
		if ($(this).is(":checked"))
		{
			$("#sales_status").show();
		}
		else
		{
			$("#sales_status").hide();
			$("#handle_status input[type='checkbox']").each(function(){
				if ($(this).is(":checked"))
				{
					$("#sales_status").show();
				}
			});
			if ($("#sales_status").is(':hidden'))
			{
				$("#sales_status input[type='checkbox']").each(function(){
					$(this).attr("checked", false);
				});
			}
		}
	});
	$("#handle_status input[type='checkbox']").each(function(){
		if ($(this).is(":checked"))
		{
			$("#sales_status").show();
		}
	});
	$("#check_all").click(function(){
		if ($(this).is(":checked"))
		{
			$(".list_table input[type='checkbox']:enabled").attr("checked", true);
		}
		else
		{
			$(".list_table input[type='checkbox']").attr("checked", false);
		}
	});
	$("#multi_trash_btn").click(function(){
		var ids = get_check();
		if (! ids)
		{
			alert("请选择销售订单！");
			return false;
		}
		$("#trash_id").val(ids);
		$("#dialog_trash").dialog("open");
	});
	var shipping_method_data = <?=$shipping_method_data?>;
	$(document).mselect(shipping_method_data, 'shipping_method_id', 'shipping_method_id', '', 'shipping_method_id');
	$("#change_shipping_method_btn").click(function(){
		var ids = get_check();
		if ( ! ids)
		{
			alert("请选择销售订单！");
			return false;
		}
		$("#change_shipping_method_id").val(ids);
		$("#dialog_change_shipping_method").dialog("open");
	});
	$("#QT_express_btn").click(function(){
		var ids = get_check();
		if (ids.length == 0)
		{
			alert("请选择销售订单");
			return false;
		}
		if ( ! confirm('确定把所选的单“同步全通广州EUB邮宝”？'))
		{
			return false;
		}
		$("#info").val(ids);
		$("#action_form").attr("action", "<?=url('Sales::Order/ExpressQT', array(Q::ini('unique_token_name')=>Helper_BSS_Normal::genToken()))?>").submit();
	});
});
</script>
<style type="text/css">
.more_content {
	position: absolute;
	top: 2px;
	left: 25px;
	width: 50px;
	background-color: #eeeeee;
	z-index: 100;
	display: none;
	border: 1px solid;
}
.complaint_click:hover{cursor: pointer;}
</style>
<form id="action_form" action="" method="post">
<input type="hidden" name="info" id="info" value="" />
<input type="hidden" name="order_type" id="order_type" value="广州E邮宝" />
<input type="hidden" name="post_type" id="post_type" value="1" />
</form>
<fieldset><legend>查询条件</legend>
<form method="get" action="">
<?include(Q::ini('custom_system/elements_dir') . 'searchform_element.php');?>
	<table class="form_table">
	<tr>
		<td colspan="4">注意：<font color="red">不需要发货的订单请废弃！</font></td>
	</tr>
	<tr>
		<th width="50">销售日期</th>
		<td>
			<input type="text" name="begin_sales_time" class="datepicker" value="<?=isset($_GET['begin_sales_time']) ? $_GET['begin_sales_time'] : ''?>" /> to
			<input type="text" name="end_sales_time" class="datepicker" value="<?=isset($_GET['end_sales_time']) ? $_GET['end_sales_time'] : ''?>" />
		</td>
		<th>制单日期</th>
		<td>
			<input type="text" name="begin_make_time" class="datepicker" value="<?=isset($_GET['begin_make_time']) ? $_GET['begin_make_time'] : ''?>" /> to
			<input type="text" name="end_make_time" class="datepicker" value="<?=isset($_GET['end_make_time']) ? $_GET['end_make_time'] : ''?>" />
		</td>
	</tr>
	<tr>
		<th>网站店铺</th>
		<td>
			<select name="shop_id[]" multiple="multiple" id="multiselect">
			<?foreach ($shop_group as $k => $sg):?>
			<optgroup label="<?=$k?>">
			<?foreach ($sg as $s):?>
			<option value="<?=$s['id']?>" <?if (isset($_GET['shop_id']) && is_array($_GET['shop_id']) && in_array($s['id'], $_GET['shop_id']))echo "selected='selected'";elseif (isset($_GET['shop_id']) && $_GET['shop_id'] == $s['id'])echo "selected='selected'"?>><?=$s['name']?></option>
			<?endforeach;?>
			</optgroup>
			<?endforeach;?>
			</select>
		</td>
		<th>仓库</th>
		<td>
			<select name="warehouse_id">
			<option value="">请选择..</option>
			<?foreach ($warehouse as $w):?>
			<option value="<?=$w['id']?>" <?if (isset($_GET['warehouse_id']) && $_GET['warehouse_id'] == $w['id'])echo "selected='selected'"?>><?=$w['name']?></option>
			<?endforeach;?>
			</select>
		</td>
	</tr>
	<tr>
		<th>本地单号</th>
		<td><input type="text" name="number" value="<?=isset($_GET['number']) ? $_GET['number'] : ''?>" /></td>
		<th>网站单号</th>
		<td><input type="text" name="shop_order_number" value="<?=isset($_GET['shop_order_number']) ? $_GET['shop_order_number'] : ''?>" /></td>
	</tr>
	<tr>
		<th>买家全名</th>
		<td><input type="text" name="fullname" value="<?=isset($_GET['fullname']) ? $_GET['fullname'] : ''?>" /></td>
		<th>买家邮箱</th>
		<td><input type="text" name="email" value="<?=isset($_GET['email']) ? $_GET['email'] : ''?>" /></td>
	</tr>
	<tr>
		<th>买家ID</th>
		<td><input type="text" name="shop_buyer_id" value="<?=isset($_GET['shop_buyer_id']) ? $_GET['shop_buyer_id'] : ''?>" /></td>
		<th>发货类型</th>
		<td>
			<select name="send_method">
				<option value="">请选择</option>
				<?foreach (Q::ini('custom_flag/sales_order_send_method') as $sm):?>
				<option value="<?=$sm['value']?>" <?if (isset($_GET['send_method']) && $_GET['send_method']==$sm['value']) echo "selected='selected'"?>><?=$sm['name']?></option>
				<?endforeach;?>
			</select>
		</td>
	</tr>
	<tr>
		<th>产品编号</th>
		<td><input type="text" name="product_number" value="<?=isset($_GET['product_number']) ? $_GET['product_number'] : ''?>" /></td>
		<th>订单金额≥</th>
		<td><input type="text" name="order_amount_more_than" value="<?=isset($_GET['order_amount_more_than']) ? $_GET['order_amount_more_than'] : ''?>" /></td>
	</tr>
	<tr>
		<th>追踪号</th>
		<td><input type="text" name="tracking_number" value="<?=isset($_GET['tracking_number']) ? $_GET['tracking_number'] : ''?>" /></td>
		<th>国家</th>
		<td><input type="text" name="country_en_cn" value="<?=isset($_GET['country_en_cn']) ? $_GET['country_en_cn'] : ''?>" /></td>
	</tr>
	<tr>
		<th>邮寄方式</th>
		<td colspan="3">
			<table>
			<?foreach ($shipping_method as $sm):?>
			<tr>
				<th><strong><?=$sm['name']?>：</strong></th>
				<td style="padding: 1px;">
					<?foreach ($sm['children'] as $v):?>
					<label style="float: left;"><input type="checkbox" name="shipping_method[<?=$v['id']?>]" value="<?=$v['id']?>" <?if (isset($_GET['shipping_method']) && array_key_exists($v['id'], $_GET['shipping_method'])) echo "checked='checked'"?> /> <?=$v['name']?>&nbsp;</label>
					<?endforeach;?>
				</td>
			</tr>
			<?endforeach;?>
			</table>
		</td>
	</tr>
	<tr id="handle_status">
		<th>订单状态</th>
		<td colspan="3">
			<?foreach (Q::ini('custom_flag/sales_order_handle_status') as $os):?>
			<label><input type="checkbox" name="order_status[<?=$os['value']?>]" value="<?=$os['value']?>" <?if (isset($_GET['order_status']) &&  array_key_exists($os['value'], $_GET['order_status'])) echo "checked='checked'"?> /> <?=$os['name']?></label>
			<?endforeach;?>
		</td>
	</tr>
	<tr style="display:none;" id="sales_status">
		<th>销售状态</th>
		<td colspan="3">
			<?foreach (Q::ini('custom_flag/product_sales_status') as $ss):?>
			<label><input type="checkbox" name="sales_status[<?=$ss['value']?>]" value="<?=$ss['value']?>" <?if (isset($_GET['sales_status'][$ss['value']]) && $_GET['sales_status'][$ss['value']] == $ss['value'])echo "checked=checked"?> /> <font color="#<?=$ss['color']?>"><?=$ss['name']?></font></label>
			<?endforeach;?>
		</td>
	</tr>
	<tr>
		<th>同步物流商</th>
		<td>
			<label><input type="checkbox" name="is_express[1]" value="1" <?if(isset($_GET['is_express']) && array_key_exists(1, $_GET['is_express'])) echo "checked='checked'";?> /> 未同步</label>
			<label><input type="checkbox" name="is_express[2]" value="2" <?if(isset($_GET['is_express']) && array_key_exists(2, $_GET['is_express'])) echo "checked='checked'";?> /> 已同步</label>
		</td>
	</tr>
	<tr>
		<th>追踪号</th>
		<td>
			<label><input type="checkbox" name="is_tracking_number[1]" value="1" <?if(isset($_GET['is_tracking_number']) && array_key_exists(1, $_GET['is_tracking_number'])) echo "checked='checked'"?> /> 无</label>
			<label><input type="checkbox" name="is_tracking_number[2]" value="2" <?if(isset($_GET['is_tracking_number']) && array_key_exists(2, $_GET['is_tracking_number'])) echo "checked='checked'"?> /> 有</label>
		</td>
	</tr>
	<tr>
		<th>产品数量</th>
		<td>
			<label><input type="checkbox" name="product_quantity_area[single]" value="single" <?if(isset($_GET['product_quantity_area']) && array_key_exists('single', $_GET['product_quantity_area'])) echo "checked='checked'";?> /> 单个</label>
			<label><input type="checkbox" name="product_quantity_area[multi]" value="multi" <?if(isset($_GET['product_quantity_area']) && array_key_exists('multi', $_GET['product_quantity_area'])) echo "checked='checked'";?> /> 多个</label>
		</td>
	</tr>
	<tr>
		<th>提示标志</th>
		<td>
			<?foreach (Q::ini('custom_flag/sales_order_tips_flag') as $sotf):?>
			<label><input type="checkbox" name="wanted_edit[<?=$sotf['value']?>]" value="<?=$sotf['value']?>" <?if (isset($_GET['wanted_edit']) &&  array_key_exists($sotf['value'], $_GET['wanted_edit'])) echo "checked='checked'"?> /> <?=$sotf['name']?></label>
			<?endforeach;?>
		</td>
	</tr>
	<tr>
		<th>同步发货</th>
		<td colspan="3">
			<?foreach (Q::ini('custom_flag/sales_order_mark_shipped_flag') as $m):?>
			<label><input type="checkbox" name="mark_shipped_flag[<?=$m['value']?>]" value="<?=$m['value']?>" <?if (isset($_GET['mark_shipped_flag']) && array_key_exists($m['value'], $_GET['mark_shipped_flag'])) echo "checked='checked'";?> /> <?=$m['name']?></label>
			<?endforeach;?>
		</td>
	</tr>
	<tr>
		<th>错漏标志</th>
		<td>
			<?foreach (Q::ini('custom_flag/sales_order_mark_order_flag') as $somof):?>
			<label><input type="checkbox" name="mark_order_flag[<?=$somof['value']?>]" value="<?=$somof['value']?>" <?if (isset($_GET['mark_order_flag']) && array_key_exists($somof['value'], $_GET['mark_order_flag'])) echo "checked='checked'"?> /><?=$somof['name']?></label>
			<?endforeach;?>
		</td>
	</tr>
	<tr>
		<th>筛选</th>
		<td>
			<label><input type="checkbox" name="is_sm" value="1" <?if (isset($_GET['is_sm']) && $_GET['is_sm'] == 1) echo "checked='checked'"?> />缺失邮寄方式</label>
		</td>
	</tr>
	<tr>
		<td></td>
		<td colspan="3">
			<input type="hidden" name="is_search" value="1" /> 
			<input type="submit" class="button" value="查找" />
		</td>
	</tr>
	</table>
</form>
</fieldset>
<?if (isset($sales_order)):?>
<table width="98%" class="list_table" id="list">
	<tr>
		<th width="30"></th>
		<th width="130">网站</th>
		<th width="90">本地单号</th>
		<th width="90">网站单号</th>
		<th width="200">买家ID</th>
		<th>买家姓名</th>
		<th width="60">金额</th>
		<th width="130">销售日期</th>
		<th width="100">状态</th>
		<th width="80">操作</th>
	</tr>
<?foreach ($sales_order as $so):?>
<tr <?if($so['warning']):?>style="background-color: #ff8800;"<?endif;?>>
	<td><input type="checkbox" value="<?=$so['id']?>" <?if(! ($so['handle_status'] == Q::ini('custom_flag/sales_order_handle_status/new/value') || $so['handle_status'] == Q::ini('custom_flag/sales_order_handle_status/sales_hold/value') || $so['handle_status'] == Q::ini('custom_flag/sales_order_handle_status/checkout/value'))):?>disabled="disabled"<?endif;?> /></td>
	<td><?=$so['shop_name']?></td>
	<td class="number<?=$so['id']?>"><?=$so['number']?></td>
	<td><?=$so['shop_order_number']?></td>
	<td <?if($so['buyerrepeat']):?>style="font-weight:bold;text-decoration:underline;"<?endif;?>>
		<?=$so['shop_buyer_id']?>
		<?if($so['product_quantity'] >= 5):?> 
		<span style="float: right;position: relative; color: red; font-weight: bold;"><?=$so['product_quantity']?></span>
		<?endif;?>
	</td>
	<td <?if($so['checkname']):?>style="background-color: #ff8800;"<?endif;?>><?=$so['fullname']?></td>
	<td><?=$so['currency_symbol']?><?=sprintf('%.2f', $so['amount'])?></td>
	<td title="销售时间：<?=$so['sales_time'] ? $so['sales_time'] : ''?> <?=$so['sales_user_name']?> 
制单时间：<?=$so['make_time'] ? $so['make_time'] : ''?> <?=$so['make_user_name']?>   
客服确认：<?=$so['checkout_time'] ? $so['checkout_time'] : ''?> <?=$so['checkout_user_name']?> 
仓库打印：<?=$so['print_time'] ? $so['print_time'] : ''?> <?=$so['print_user_name']?> 
出库时间：<?=$so['shipped_time'] ? $so['shipped_time'] : ''?> <?=$so['shipped_user_name']?>"><?=$so['sales_time'] ?>
	</td>
	<td>
		<?=Helper_BSS_Normal::getIniOne('sales_order_handle_status', 'value', $so['handle_status'], 'name')?>
		<span title="<?=Helper_BSS_Normal::getIniOne('sales_order_handle_status', 'value', $so['handle_status'], 'name')?>" class="<?=Helper_BSS_Normal::getIniOne('sales_order_handle_status', 'value', $so['handle_status'], 'icon_class')?>"></span>
		<?if ($so['has_sales_notes']):?><span class="sales_notes_icon"></span><?endif;?>
		<?if ($so['has_warehouse_notes']):?><span class="warehouse_notes_icon"></span><?endif;?>
		<?if ($so['has_customer_notes']):?><span class="customer_notes_icon"></span><?endif;?>
		<?if ($so['has_sales_refund']):?><span class="refund_icon"></span><?endif;?>
		<?if ($so['tips_flag']):?><span title="<?=Helper_BSS_Normal::getIniOne('sales_order_tips_flag', 'value', $so['tips_flag'], 'name')?>" class="<?=Helper_BSS_Normal::getIniOne('sales_order_tips_flag', 'value', $so['tips_flag'], 'icon_class')?>"></span><?endif;?>
		<?if ($so['mark_order_flag']):?><span class="wrong_icon" title="错落发"></span><?endif;?>
	</td>
	<td>
		<a class="view" href="javascript:void(0);">查看</a>
		<div style="float: right;position: relative;">
		<a class="more_click">更多&or;</a>
		<ul class="more_content">
			<?if ($so['handle_status'] == Q::ini('custom_flag/sales_order_handle_status/new/value') || $so['handle_status'] == Q::ini('custom_flag/sales_order_handle_status/sales_hold/value')):?>
			<li><a href="<?=url('Sales::Order/OrderInfoEdit', array('id'=>$so['id']))?>">改订单</a></li>
			<?endif;?>
			<?if ($so['handle_status'] == Q::ini('custom_flag/sales_order_handle_status/new/value') || $so['handle_status'] == Q::ini('custom_flag/sales_order_handle_status/sales_hold/value')):?>
			<li><a href="<?=url('Sales::Order/ProductInfoEdit', array('id'=>$so['id']))?>">改产品</a></li>
			<?endif;?>
			<li>
				<a href="javascript:void(0);" class="markorder_click">标识错漏</a>
				<input type="hidden" value="<?=$so['id']?>" />
			</li>
			<li>
				<a href="javascript:void(0);" class="addnotes_click">消息备注</a>
				<input type="hidden" value="<?=$so['id']?>" />
			</li>
			<li>
				<a href="javascript:void(0);" class="addordernotes_click">订单备注</a>
				<input type="hidden" value="<?=$so['id']?>" />
			</li>
			<?if ($so['handle_status'] == Q::ini('custom_flag/sales_order_handle_status/new/value') || $so['handle_status'] == Q::ini('custom_flag/sales_order_handle_status/sales_hold/value') || $so['handle_status'] == Q::ini('custom_flag/sales_order_handle_status/shipped/value') || $so['handle_status'] == Q::ini('custom_flag/sales_order_handle_status/return/value')):?>
			<li>
				<a href="javascript:void(0);" class="refund_click">退款单</a>
				<input type="hidden" value="<?=$so['id']?>" />
			</li>
			<?endif;?>
			<?if ($so['handle_status'] == Q::ini('custom_flag/sales_order_handle_status/shipped/value')):?>
			<li>
				<a target="_blank" href="<?=url('Sales::Order/ReturnCreate', array('id'=>$so['id']))?>" onclick="if(!confirm('确定退货？')) return false;">退货单</a>
				<input type="hidden" value="<?=$so['id']?>" />
			</li>
			<?endif;?>
			<?if ($so['handle_status'] == Q::ini('custom_flag/sales_order_handle_status/new/value') || $so['handle_status'] == Q::ini('custom_flag/sales_order_handle_status/sales_hold/value')):?>
			<li>
				<a href="javascript:void(0);" class="trash_click">废弃单</a>
				<input type="hidden" value="<?=$so['id']?>" />
			</li>
			<li><a target="_blank" href="<?=url('Sales::Order/Create', array('id'=>$so['id'], 'type' => true))?>" onclick="if(!confirm('确定复制订单？')) return false;">复制订单</a></li>
			<li><a target="_blank" href="<?=url('Sales::Order/Create', array('id'=>$so['id']))?>" onclick="if(!confirm('确定复制订单地址信息？')) return false;">复制地址</a></li>
			<?endif;?>
			<?if ($so['handle_status'] == Q::ini('custom_flag/sales_order_handle_status/shipped/value') || $so['handle_status'] == Q::ini('custom_flag/sales_order_handle_status/return/value')):?>
			<li><a target="_blank" href="<?=url('Sales::Order/Create', array('id'=>$so['id'], 'type' => true))?>" onclick="if(!confirm('确定录制重发单？')) return false;">录重发单</a></li>
			<?endif;?>
			<?if ($so['handle_status'] == Q::ini('custom_flag/sales_order_handle_status/new/value') or $so['handle_status'] == Q::ini('custom_flag/sales_order_handle_status/sales_hold/value')):?>
			<li><a href="javascript:void(0);" class="combine_click">合并订单</a><input type="hidden" value="<?=$so['id']?>" /></li>
			<?endif;?>
			<?if ($so['handle_status'] == Q::ini('custom_flag/sales_order_handle_status/assigned/value') or $so['handle_status'] == Q::ini('custom_flag/sales_order_handle_status/printed/value') or $so['handle_status'] == Q::ini('custom_flag/sales_order_handle_status/printed_address/value') or $so['handle_status'] == Q::ini('custom_flag/sales_order_handle_status/weighed/value') or $so['handle_status'] == Q::ini('custom_flag/sales_order_handle_status/warehouse_hold/value')):?>
			<li><a href="<?=url('Sales::Order/WantedEdit', array('id'=>$so['id']))?>" class="wanted_edit_click">需要改单</a><input type="hidden" value="<?=$so['id']?>" /></li>
			<?endif;?>
		</ul>
		</div>
	</td>
</tr>
<tr class="detail" style="display: none;">
	<td colspan="25">
		<table width="100%" class="list_table">
			<tr>
				<th width="15%">仓库</th>
				<td width="35%"><?=$so['warehouse_name']?></td>
				<th width="15%">制单人</th>
				<td width="35%"><?=$so['make_user_name']?></td>
			</tr>
			<tr>
				<th width="15%">发货类型</th>
				<td width="35%">
					<?=Helper_BSS_Normal::getIniOne('sales_order_send_method', 'value', $so['send_method'], 'name')?>
					<?=Helper_BSS_Normal::getIniOne('sales_order_resend_reason', 'value', $so['resend_reason'], 'name') ? '('.Helper_BSS_Normal::getIniOne('sales_order_resend_reason', 'value', $so['resend_reason'], 'name').')' : ''?>
				</td>
				<th>支付方式</th>
				<td><?=Helper_BSS_Normal::getIniOne('sales_order_payment_method', 'value', $so['payment_method'], 'name')?></td>
			</tr>
			<tr>
				<th>邮寄方式/追踪号</th>
				<td><?=$so['shipping_method_name']?><?=$so['tracking_number'] ? ('/' . $so['tracking_number']) : ''?></td>
				<th>交易号</th>
				<td><?=$so['transaction_id']?></td>
			</tr>
			<tr>
				<th>买家姓名</th>
				<td><?=$so['fullname']?></td>
				<th>买家Email</th>
				<td><?=$so['email']?></td>
			</tr>
			<tr>
				<th>买家电话</th>
				<td><?=$so['phone']?></td>
				<th>收货地址1</th>
				<td><?=$so['street1']?></td>
			</tr>
			<tr>
				<th>收货地址2</th>
				<td><?=$so['street2']?></td>
				<th>城市</th>
				<td><?=$so['city']?></td>
			</tr>
			<tr>
				<th>州/省</th>
				<td><?=$so['state']?></td>
				<th>邮政编码</th>
				<td><?=$so['zip']?></td>
			</tr>
			<tr>
				<th>国家</th>
				<td><?=$so['country']?></td>
				<th>国家(中文)</th>
				<td><?=$so['country_cn']?></td>
			</tr>
			<tr>
				<th>收取运费</th>
				<td><?=$so['currency_symbol']?><?=sprintf('%.2f', $so['shipping_fee'])?></td>
				<th>折扣</th>
				<td><?=$so['currency_symbol']?><?=sprintf('%.2f', $so['discount'])?></td>
			</tr>
			<tr>
				<th>重量（系统估算/实际称重）</th>
				<td><?=sprintf('%.2f', $so['estimated_weight'])?>g / <?=sprintf('%.2f', $so['weight'])?>g</td>
				<th>发货物流费用</th>
				<td><?=$so['postage_currency_symbol']?><?=sprintf('%.2f', $so['postage'])?></td>
			</tr>
			<?if ($so['address_notes']):?>
			<tr>
				<th>地址备注</th>
				<td align="left" colspan="3"><?=$so['address_notes']?></td>
			</tr>
			<?endif;?>
			<?if ($so['order_notes']):?>
			<tr>
				<th>订单备注</th>
				<td align="left" colspan="3">
				<?foreach ($so['order_notes'] as $son):?>
				<p><?=$son['notes_name']?>(<?=$son['add_time']?>):<?=$son['notes']?></p>
				<?endforeach;?>
				</td>
			</tr>
			<?endif;?>
			<?if ($so['sales_notes'] || $so['warehouse_notes']):?>
			<tr>
				<th>消息备注</th>
				<td align="left" colspan="3">
				<?foreach ($so['sales_notes'] as $ssn):?>
				<p><?=$ssn['notes_name']?>(<?=$ssn['add_time']?>):<?=$ssn['notes']?></p>
				<?endforeach;?>
				<?foreach ($so['warehouse_notes'] as $ssn):?>
				<p><?=$ssn['notes_name']?>(<?=$ssn['add_time']?>):<?=$ssn['notes']?></p>
				<?endforeach;?>
				</td>
			</tr>
			<?endif;?>
			<?if ($so['customer_notes']):?>
			<tr>
				<th>客人备注</th>
				<td align="left" colspan="3">
				<?foreach($so['customer_notes'] as $scn):?>
				<p><?=$scn['notes']?></p>
				<?endforeach;?>
				</td>
			</tr>
			<?endif;?>
			<?if (isset($so['sales_refund']) && $so['has_sales_refund']):?>
			<tr>
				<th>退款信息</th>
				<td align="left" colspan="3">
				<?foreach ($so['sales_refund'] as $ssr):?>
				<p><?=$ssr['refund_account']?>/<?=Helper_BSS_Normal::getIniOne('sales_order_payment_method', 'value', $ssr['refund_method'], 'name')?>(<?=$so['currency_symbol']?><?=$ssr['refund_amount']*$ssr['type']?>):<?=Helper_BSS_Normal::getIniOne('sales_refund_reason', 'value', $ssr['reason'], 'name')?></p>
				<?endforeach;?>
				</td>
			</tr>
			<?endif;?>
		</table>
		<div align="left"><strong>销售订单产品信息</strong></div>
		<table width="100%" class="list_table">
			<tr>
				<th>产品编号</th>
				<th>单价</th>
				<th>数量</th>
				<th>金额</th>
				<th>最低售价</th>
				<th>销售状态</th>
				<th>可用库存</th>
				<th>ShopItemId</th>
				<th>ShopTransactionId</th>
			</tr>
			<?$total_quantity = 0;?>
			<?$total_amount = 0;?>
			<?foreach ($so['item'] as $soi):?>
			<?$item_price = $soi['sales_price'];?>
			<?$total_quantity += $soi['quantity']?>
			<tr>
				<td title="<?=$soi['product_name']?>">
					<?=$soi['number']?>
					<?if ($soi['pic_url']):?>
						<?$pretty_photo_number = 0;?>
						<?foreach ($soi['pic_url'] as $soip):?>
						<a rel="pretty_photo[<?=$soi['id']?>]" href="<?=$soip?>"><?if(!$pretty_photo_number):?><span class="img_icon"></span><?endif;?></a>
						<?$pretty_photo_number = 1;?>
						<?endforeach;?>
					<?endif;?>
				</td>
				<td>
					<?=$so['currency_symbol']?><?=sprintf('%.2f',$soi['sales_price'])?>
					<?foreach ($soi['attr'] as $soia):?>
					<?if ($soia['price'] != 0):?>
					<p><?=$soia['prefix']?><?=$so['currency_symbol']?><?=sprintf('%.2f',$soia['price'])?></p>
						<?if ($soia['prefix'] == '+'):?><?$item_price += $soia['price'];?><?endif;?>
						<?if ($soia['prefix'] == '-'):?><?$item_price -= $soia['price'];?><?endif;?>
					<?endif;?>
					<?endforeach;?>
					<?$item_amount = $item_price * $soi['quantity'];?>
					<?$total_amount += $item_amount;?>
				</td>
				<td><?=$soi['quantity']?></td>
				<td><?=$so['currency_symbol']?><?=sprintf('%.2f',$item_amount)?></td>
				<td><?=$so['currency_symbol']?><?=sprintf('%.2f',$soi['floor_price'])?></td>
				<td><font color="#<?=Helper_BSS_Normal::getIniOne('product_sales_status', 'value', $soi['sales_status'], 'color')?>"><?=Helper_BSS_Normal::getIniOne('product_sales_status', 'value', $soi['sales_status'], 'name')?></font></td>
				<td><?=($soi['available_quantity']<$soi['quantity']) ? "<span class='red'>{$soi['available_quantity']}</span>" : $soi['available_quantity'] ?></td>
				<td><?=$soi['shop_item_id']?></td>
				<td><?=$soi['shop_transaction_id']?></td>
			</tr>
			<?endforeach;?>
			<tr>
				<td colspan="2">小计</td>
				<td><?=$total_quantity?></td>
				<td><?=$so['currency_symbol']?><?=sprintf('%.2f', $total_amount);?></td>
				<td colspan="5"></td>
			</tr>
			<tr>
				<td colspan="3">总计</td>
				<td><?=$so['currency_symbol']?><?=sprintf('%.2f',$so['amount'])?></td>
				<td colspan="5"></td>
			</tr>
			<tr>
				<td colspan="10">
					<input type="button" class="button checkout_btn" value="确认订单" <?if(!($so['handle_status'] == Q::ini('custom_flag/sales_order_handle_status/new/value') || $so['handle_status'] == Q::ini('custom_flag/sales_order_handle_status/sales_hold/value'))):?>disabled="disabled"<?endif;?>/>
					<input type="hidden" class="button" value="<?=$so['id']?>" />
					<input type="button" class="button hold_btn" value="滞留订单" <?if($so['handle_status']!=Q::ini('custom_flag/sales_order_handle_status/new/value') && $so['handle_status']!=Q::ini('custom_flag/sales_order_handle_status/checkout/value')):?>disabled="disabled"<?endif;?> />
					<input type="button" class="button trash_btn" value="废弃订单" <?if($so['handle_status']!=Q::ini('custom_flag/sales_order_handle_status/new/value') && $so['handle_status']!=Q::ini('custom_flag/sales_order_handle_status/sales_hold/value')):?>disabled="disabled"<?endif;?> />
					<?if ($so['shipping_method'] == Shipping_Method::getShippingMethodByCode('GZ_N_EUB')):?>
					<input type="button" class="button post_eub_btn" <?if (($so['tracking_number'] && is_file(Q::ini('custom_system/eub_label_dir').$so['number'].'.pdf')) || $so['handle_status'] == Q::ini('custom_flag/sales_order_handle_status/shipped/value') || $so['handle_status'] == Q::ini('custom_flag/sales_order_handle_status/return/value')):?>disabled="disabled"<?endif;?> value="同步E邮宝" /><span></span>
					<?endif;?>
					<?if ($so['tracking_number'] && is_file(Q::ini('custom_system/eub_label_dir').$so['number'].'.pdf') && $so['shipping_method'] == Shipping_Method::getShippingMethodByCode('GZ_N_EUB') && ($so['handle_status'] == Q::ini('custom_flag/sales_order_handle_status/new/value') || $so['handle_status'] == Q::ini('custom_flag/sales_order_handle_status/sales_hold/value'))):?>
					<input type="button" class="button removed_eub_btn" value="清除EUB"/><span></span>
					<?endif;?>
					<?if ($so['shipping_method'] == Shipping_Method::getShippingMethodByCode('GZ_N_IEUB')):?>
					<input type="button" class="button post_ieub_btn" <?if (($so['tracking_number'] && is_file(Q::ini('custom_system/eub_label_dir').$so['number'].'.pdf')) || $so['handle_status'] == Q::ini('custom_flag/sales_order_handle_status/shipped/value') || $so['handle_status'] == Q::ini('custom_flag/sales_order_handle_status/return/value')):?>disabled="disabled"<?endif;?> value="同步国际EUB" /><span></span>
					<?endif;?>
					<?if ($so['tracking_number'] && is_file(Q::ini('custom_system/eub_label_dir').$so['number'].'.pdf') && $so['shipping_method'] == Shipping_Method::getShippingMethodByCode('GZ_N_IEUB') && ($so['handle_status'] == Q::ini('custom_flag/sales_order_handle_status/new/value') || $so['handle_status'] == Q::ini('custom_flag/sales_order_handle_status/sales_hold/value'))):?>
					<input type="button" class="button removed_ieub_btn" value="清除国际EUB"/><span></span>
					<?endif;?>
				</td>
			</tr>
		</table>
	</td>
</tr>
<?endforeach;?>
</table>
<?=$page?>
<table class="list_table">
<tr>
	<td rowspan="1"><label><input type="checkbox" id="check_all" />全选</label></td>
	<td align="left">
		<input type="button" class="button multi_checkout_btn" value="批量确认" />
	</td>
	<td align="left">
		<input type="button" class="button multi_hold_btn" value="批量滞留" />
	</td>
	<td align="left">
		<input type="button" class="button" id="multi_trash_btn" value="批量废弃订单" />
	</td>
	<td align="left">
		<input type="button" class="button" id="change_shipping_method_btn" value="修改邮寄方式" />
	</td>
	<td align="left">
		<input type="button" class="button" id="QT_express_btn" value="同步全通EUB" />
	</td>
</tr>
</table>
<form id="action_form" action="" method="post">
<input type="hidden" name="info" id="info" value="" />
</form>
<div id="dialog_trash" title="填写废弃原因">
<form method="post" action="<?=url('Sales::Order/Trash')?>">
<input type="hidden" name="id" id="trash_id" value="" />
<textarea name="trash_reason" rows="3" cols="30">合并单</textarea>
<input type="submit" value="转为废弃单" class="button" />
<input type="hidden" name="<?=Q::ini('unique_token_name');?>" value="<?=Helper_BSS_Normal::genToken();?>"/>
</form>
</div>
<div id="dialog_combine" title="填写合并订单号">
<form method="post" action="<?=url('Sales::Order/Combine')?>">
<input type="hidden" name="id" id="combine_order_id" value="" />
<textarea id="number" name="number" rows="10" cols="25"></textarea>
<p>说明：多个订单号用回车分开</p>
<input type="submit" value="合并" class="button" />
<input type="hidden" name="<?=Q::ini('unique_token_name');?>" value="<?=Helper_BSS_Normal::genToken();?>"/>
</form>
</div>
<div id="dialog_notes" title="消息备注">
<form method="post" action="<?=url('Sales::Order/AddNotes')?>">
<input type="hidden" name="id" id="notes_id" value="" />
<textarea name="notes_content" rows="15" cols="60"></textarea><br>
<input type="submit" value="添加备注" class="button" />
</form>
</div>
<div id="dialog_order_notes" title="订单备注">
<form method="post" action="<?=url('Sales::Order/AddOrderNotes')?>">
<input type="hidden" name="id" id="order_notes_id" value="" />
<textarea name="notes_content" rows="15" cols="60"></textarea><br>
<input type="submit" value="添加备注" class="button" />
</form>
</div>
<div id="dialog_markorder" title="请选择漏/错发订单原因">
<form method="post" action="<?=url('Sales::Order/MarkOrder')?>">
<table class="form_table">
<tr>
	<td>
		<?foreach (Q::ini('custom_flag/sales_order_mark_order_flag') as $somof):?>
		<label><input type="radio" name="markorder_reason" value="<?=$somof['value']?>" /> <?=$somof['name']?></label><br>
		<?endforeach;?>
	</td>
</tr>
<tr>
	<th><input type="hidden" name="id" id="markorder_id" value="" /></th>
	<td colspan="2"><input type="submit" value="确定" class="button" /></td>
</tr>
</table>
</form>
</div>
<div id="dialog_refund" title="填写退款信息">
<form method="post" action="<?=url('Sales::Order/Refund')?>">
<table class="form_table">
<tr>
	<th>退款类型</th>
	<td>
		<select name="type">
			<option value="-1">-</option>
			<option value="1">+</option>
		</select>
	</td>
	<th>退款金额</th>
	<td><input type="text" name="refund_amount" value="" /></td>
</tr>
<tr>
	<th>退款账号</th>
	<td><input type="text" name="refund_account" value="" /></td>
	<th>收款交易号</th>
	<td><input type="text" name="receive_transaction_id" value="" /></td>
</tr>
<tr>
	<th>退款方式</th>
	<td>
		<select name="refund_method">
			<option value="">请选择..</option>
			<?foreach (Q::ini('custom_flag/sales_order_payment_method') as $pm):?>
			<option <?if(isset($so) && $so['payment_method']==$pm['value']) echo "selected='selected'"?> value="<?=$pm['value']?>"><?=$pm['name']?></option>
			<?endforeach;?>
		</select>
	</td>
	<th>商品类别</th>
	<td><input type="text" name="categories_name" value="" /></td>
</tr>
<tr>
	<th>退款原因</th>
	<td>
		<select name="reason">
			<option value="">请选择..</option>
			<?foreach (Q::ini('custom_flag/sales_refund_reason') as $srr):?>
			<option value="<?=$srr['value']?>"><?=$srr['name']?></option>
			<?endforeach;?>
		</select>
	</td>
	<th>备注</th>
	<td colspan="3"><textarea name="notes" rows="3" cols="22"></textarea></td>
</tr>
<tr>
	<th><input type="hidden" name="id" id="refund_id" value="" /></th>
	<td colspan="2"><input type="submit" value="提交退款单" class="button" /><input type="hidden" name="<?=Q::ini('unique_token_name');?>" value="<?=Helper_BSS_Normal::genToken();?>"/></td>
</tr>
</table>
</form>
</div>
<div id="dialog_change_shipping_method" title="批量修改订单邮寄方式">
<form method="post" action="<?=url('Sales::Order/ChangeShippingMethod')?>">
	<input type="hidden" name="id" id="change_shipping_method_id" value="" />
	<table class="form_table">
		<tr>
			<td>邮寄方式</td>
			<td><input type="hidden" name="shipping_method_id" id="shipping_method_id" value="" /></td>
		</tr>
		<tr>
			<td></td>
			<td><input type="submit" class="button" value="确认更改" /></td>
		</tr>
	</table>
</form>
</div>
<?endif;?>
<?php $this->_endblock(); ?> 
